#include "stdafx.h"
#include"WLFileManager.h"
#include <stdio.h>

WLResource* WLFileManager:: LoadFileToResource(WLResource* Res,char* FileName )
{
	if ( !FileName )
		return NULL;
	FILE *pFile = ::fopen(FileName,"r");

	if ( !pFile )
		return NULL;

	fseek(pFile,0,SEEK_END);
	unsigned int size = ftell(pFile);
	fseek(pFile,0,SEEK_SET);
	char* Buffer = new char[size];
	::fread(Buffer,sizeof(char),size,pFile);
	WLArchive Ar(Buffer);
	Ar<<Res;
	Res->Build();

	delete[] Buffer;
	Buffer = NULL;
	::fclose(pFile);
	return Res;
}
